#ifndef __GLBVAR_H
#define __GLBVAR_H

//----------------------------------Include-------------------------------------
#include  <stdint.h>
//------------------------------------------------------------------------------

//-----------------------------------Macro--------------------------------------
#define countof(Obj)  (sizeof(Obj)/sizeof(Obj[0]))
//------------------------------------------------------------------------------
#define BSWAP_16(x) \
        (uint16_t)((((uint16_t)(x) & 0x00ff) << 8) | \
                   (((uint16_t)(x) & 0xff00) >> 8) )
#define BSWAP_32(x) \
        (uint32_t)((((uint32_t)(x) & 0xff000000) >> 24) | \
                   (((uint32_t)(x) & 0x00ff0000) >>  8) | \
                   (((uint32_t)(x) & 0x0000ff00) <<  8) | \
                   (((uint32_t)(x) & 0x000000ff) << 24) )
//------------------------------------------------------------------------------
#define GM_SAMP_FRQ        (1600)
#define GM_BASE_FRQ          (50)
#define GM_SAMP_LEN        (1024)
#define GM_FFT_NUM         (1024)
#define GM_NEED_PT         (16-1)
//------------------------------------------------------------------------------

//-----------------------------------Types--------------------------------------
//------------------------------------------------------------------------------

//---------------------------------Share Var------------------------------------
#ifdef  APP_GLOBALS
#else
extern  uint64_t     igu64_tick_ms;
extern  uint32_t     igu32_bufflag;

#if 1
extern  float        igaf_adc_u[GM_SAMP_LEN];   //sample result
extern  float        igaf_adc_i[GM_SAMP_LEN];
extern  float         gaf_fft_u[GM_FFT_NUM*2];  //fft result
extern  float         gaf_fft_i[GM_FFT_NUM*2];

//extern  float         gaf_amp_u[GM_FFT_NUM/2];
//extern  float         gaf_amp_i[GM_FFT_NUM/2];
extern  double        gaf_pt_amp_u[GM_NEED_PT];
extern  double        gaf_pt_amp_i[GM_NEED_PT];
#else
extern  q15_t        igqx_adc_u[GM_SAMP_LEN];   //sample result
extern  q15_t        igqx_adc_i[GM_SAMP_LEN];
extern  q15_t         gqx_fft_u[GM_FFT_NUM*2];  //fft result
extern  q15_t         gqx_fft_i[GM_FFT_NUM*2];

extern  q15_t         gqx_pt_amp_u[GM_NEED_PT];
extern  q15_t         gqx_pt_amp_i[GM_NEED_PT];
#endif

extern  double        gf_rms_u;
extern  double        gf_rms_i;
extern  double        gf_pwr_p;
extern  double        gf_pwr_q;
extern  double        gf_pwr_s;
extern  double        gf_factor;
extern  double        gf_thd;

extern  double        gf_coeff_u;
extern  double        gf_coeff_i;
extern  uint32_t      gu32_turns;
#endif
//------------------------------------------------------------------------------

//----------------------------------Declare-------------------------------------
//------------------------------------------------------------------------------

#endif
//------------------------------------EOF---------------------------------------


